package gamecode;

public class DPoint {

	private double x, y;
	
	public DPoint() {
		x = 0;
		y = 0;
	}
	
	public DPoint(double nx, double ny) {
		this.x = nx;
		this.y = ny;
	}
	
	public void setLocation(double nx, double ny) {
		this.x = nx;
		this.y = ny;
	}
	
	public void setLocation(DPoint p) {
		this.x = p.getX();
		this.y = p.getY();
	}
	
	public double getX() {
		return x;
	}
	
	public double getY() {
		return y;
	}
	
	public void translate(double nx, double ny) {
		this.x += nx;
		this.y += ny;
	}

	public void translate(DPoint XY) {
		this.x += XY.getX();
		this.y += XY.getY();
	}
	
	public Vector2D getVector2D() {
		double m = Math.sqrt((this.getX()*this.getX()) + (this.getY()*this.getY()));
		double d = Math.toDegrees(Math.atan2(this.getY(), this.getX()));
		if (Double.isNaN(d)) d = 0;
		return new Vector2D(m, d);
	}
	
	public static Vector2D getVector2D(DPoint xy) {
		double m = Math.sqrt((xy.getX()*xy.getX()) + (xy.getY()*xy.getY()));
		double d = Math.toDegrees(Math.atan2(xy.getY(), xy.getX()));
		if (Double.isNaN(d)) d = 0;
		return new Vector2D(m, d);
	}
}
